package com.jblapp.icu.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class ContactDBHelper extends SQLiteOpenHelper {
	private static final String CONTACT_DATABASE_NAME = "icu_contact.db";
	private static final int CONTACT_DATABASE_VERSION = 1;
	private static SQLiteOpenHelper mInstance;
	
	private ContactDBHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}
	
	public synchronized static SQLiteOpenHelper getInstance(Context context){
		if(mInstance == null){
			mInstance = new ContactDBHelper(context, CONTACT_DATABASE_NAME, null, CONTACT_DATABASE_VERSION);
		}
		return mInstance;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL("CREATE TABLE icucontact(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
				"contact_id INTEGER, " +
				"name TEXT, " +
				"salutation TEXT, " +
				"phone TEXT, " +
				"face TEXT, " +
				"sex VARCHAR, " +
				"signed TEXT, " +
				"sort_key, " +
				"localface_path TEXT, " +
				"contacttype INTEGER)");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub

	}

}
